package solved;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Comparator;

/*
 ID:	liluyan1
 LANG:	JAVA
 TASK:	milk
 */
public class milk {
	public static void main(String[] args) throws IOException {
		BufferedReader f = new BufferedReader(new FileReader("milk.in"));
		int res = new milk().solve(f);
		
		PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter(
				"milk.out")));
		out.println(res);
		out.close();
		System.exit(0);
	}
	
	private int solve(BufferedReader f) throws IOException {
		int[] t = read(f);
		int N = t[0];
		int M = t[1];
		Farmer[] farmers = new Farmer[M];
		for (int i=0; i<M; i++) {
			t = read(f);
			farmers[i] = new Farmer(t[0], t[1]);
		}
		
		Arrays.sort(farmers, new Comparator<Farmer>() {
			public int compare(Farmer a, Farmer b) {
				return a.price - b.price;
			}
		});
		
		int cost = 0;
		for (int i=0; i<M; i++) {
			if (N > farmers[i].amount) {
				cost += farmers[i].price * farmers[i].amount;
				N -= farmers[i].amount;
			}
			else {
				cost += farmers[i].price * N;
				break;
			}
		}
		
		return cost;
	}
	
	private int[] read(BufferedReader f) throws IOException {
		String[] t = f.readLine().split(" ");
		return new int[]{Integer.parseInt(t[0]), Integer.parseInt(t[1])};
	}
	
	private class Farmer {
		int price;
		int amount;
		public Farmer(int price, int amount) {
			this.price = price;
			this.amount = amount;
		}
	}
}
